{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# 第二节 微积分"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 1. 迭代法求解二次函数最小值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD4CAYAAAD1jb0+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3dd3iV9f3/8ec7iwwSIJCEkA2EETaEJeJgKKLitqBQtFTocFSrVn622qW1tl9Hbaug4AKhuCoqDrQIsgmbEEYYGQRICBCy1/n8/kjsRTFAknNO7nOfvB/X5QU5OeR+IfDi5v4sMcaglFLKfnysDqCUUqp5tMCVUsqmtMCVUsqmtMCVUsqmtMCVUsqm/FryYp06dTKJiYkteUmllLK9zZs3nzDGRJz7eosWeGJiImlpaS15SaWUsj0RyWrodX2EopRSNqUFrpRSNqUFrpRSNqUFrpRSNqUFrpRSNnXRAheR+SKSLyK7znn9PhHZKyLpIvKs+yIqpZRqSGPuwN8AJpz9gohcCdwA9DfG9AH+6vpoSimlLuSiBW6MWQWcPOflnwLPGGMq69+T74Zs//Xt/gL++U2mOy+hlFJuUVZVw+8+TiersNTlX7u5z8B7AKNFZIOIrBSRoed7o4jMFJE0EUkrKCho1sVW7z/Bc1/uI/9MRTPjKqWUNT7ZfpTX1xwmv7jS5V+7uQXuB3QARgCPAEtERBp6ozFmrjEm1RiTGhHxvZWgjfKDoXHUOAzvbs5tZlyllLLGok3ZdI9sS2pCB5d/7eYWeC7wgamzEXAAnVwX6391jWjLyK4dWbwpG4dDTxBSStnDnmNn2Jp9mslD4zjPPa5Tmlvg/wbGAIhIDyAAOOGqUA2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ev/84g/hyISC1wLvObqr22rAheRScARY8x2q7OcS0SeEpEc4E485w78bD8CPrM6hAeKAXLO+jgXDygkOxCRRGAQsMHaJHXqH1NsA/KB5cYYj8gFvEDdTafD1V/YqTMx3UFEvgI6N/Cpx4H/B1zVsonqXCiXMeYjY8zjwOMiMhu4F3jSE3LVv+dx6v7pu7AlMjU2l4eQBl7ziDs3TyYibYH3gV+c8y9QyxhjaoGB9WM9H4pIX2OMpWMIInIdkG+M2SwiV7j663tcgRtjxjX0uoj0A5KA7SICdY8DtojIMGPMMatyNeAd4FNaqMAvlktEpgPXAWNNC076b8L/L6vlAnFnfRwL5FmUxRZExJ+68l5ojPnA6jznMsacFpFvqBtDsHoQeBQwSUQmAoFAmIgsMMZMdcUXt80jFGPMTmNMpDEm0RiTSN0fvMEtUd4XIyLJZ304CdhjVZazicgE4FfAJGNMmdV5PNQmIFlEkkQkAJgMLLU4k8eSuruneUCGMeY5q/N8R0QivptlJSJBwDg84M+hMWa2MSa2vrMmA/9xVXmDjQrcwz0jIrtEZAd1j3g8YmoV8HcgFFheP8XxFasDAYjITSKSC4wEPhWRL6zKUj/Iey/wBXUDckuMMelW5fmOiCwC1gE9RSRXRGZYnaneKGAaMKb+99S2+rtLq0UDK+r/DG6i7hm4S6fseSJdSq+UUjald+BKKWVTWuBKKWVTWuBKKWVTWuBKKWVTWuBKKWVTWuBKKWVTWuBKKWVT/x9doJCU/L/iAwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "最终x的值为： -0.009671406556917058\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "from IPython import display\n",
    "\n",
    "# 定义二次函数\n",
    "def f(x):\n",
    "    y = x**2\n",
    "    return y\n",
    "\n",
    "# 定义对应的导数\n",
    "def d(x):\n",
    "    dy = 2*x\n",
    "    return dy\n",
    "\n",
    "# 操作者输入指定的x初始值\n",
    "x = float(input(\"请输入x的初始值：\"))\n",
    "\n",
    "# 定义学习率\n",
    "lr = 0.9\n",
    "\n",
    "# 准备一段二次函数数据点\n",
    "x_temp = np.linspace(-x, x, 1000)\n",
    "y_temp = x_temp**2\n",
    "\n",
    "while abs(x) > 0.01:\n",
    "    display.clear_output(wait=True)   # 用于清空之前的输出\n",
    "    plt.clf()                         # 清除之前的列表\n",
    "    plt.plot(x_temp, y_temp)\n",
    "    plt.scatter(x, f(x), s=30, c='red')\n",
    "    plt.show()\n",
    "    print(\"此时x的值为：\", x)\n",
    "    plt.pause(0.7)\n",
    "    %matplotlib inline\n",
    "    dy = d(x)\n",
    "    x -= lr * dy\n",
    "else:\n",
    "    display.clear_output(wait=True)   \n",
    "    plt.clf()\n",
    "    plt.plot(x_temp, y_temp)\n",
    "    plt.scatter(x, f(x), s=30, c='red')\n",
    "    plt.show()\n",
    "    print(\"最终x的值为：\", x)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 2. 求规则图形的面积"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD4CAYAAADiry33AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3dd3yV9fn/8dfFlr2HQAjIkh2NyNC6KcVBqaLQqmixaFsFcYFat23dA61VqlatmjBV6gRXcdQBJGHvGVbYhBGyrt8fOX5/FBMJyUnuk3Pez8eDx7nP577vc1+HhPe5ue/7XLe5OyIiEr0qBV2AiIiULQW9iEiUU9CLiEQ5Bb2ISJRT0IuIRLkqQRdQmMaNG3t8fHzQZYi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iUAQW9iEiUU9CLiEQ5Bb2ISJRT0IuIRDkFvYhIlFPQi4hEuf8HL8OVUtjTgXwAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "from IPython import display\n",
    "\n",
    "x_temp = np.linspace(1, 10, 1000)\n",
    "y_temp = 2*x_temp + 3\n",
    "\n",
    "%matplotlib inline\n",
    "plt.plot(x_temp, y_temp)\n",
    "plt.xlim(0,11)\n",
    "plt.show()\n",
    "# display.clear_output(wait=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "请输入第一个点的横坐标值： 1\n",
      "请输入第二个点的横坐标值： 10\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "此梯形的面积为： 126.0\n"
     ]
    }
   ],
   "source": [
    "def reg_area(p1, p2):\n",
    "    # p1, p2: 点的坐标\n",
    "    if p1[0] < 0 or p1[1] < 0 or p2[0] < 0 or p2[1] < 0:\n",
    "        print(\"点坐标为负，非法！\")   # 若点的坐标有负值，则不可计算\n",
    "        return -1\n",
    "    height = abs(p2[0] - p1[0])  # 求梯形的高\n",
    "    l1 = p1[1]   # 求一个底的长\n",
    "    l2 = p2[1]   # 求另一个底的长\n",
    "    area = (l1 + l2)*height/2\n",
    "    return area\n",
    "\n",
    "def f1(x):\n",
    "    return 2*x+3\n",
    "\n",
    "x1 = float(input(\"请输入第一个点的横坐标值：\"))\n",
    "x2 = float(input(\"请输入第二个点的横坐标值：\"))\n",
    "y1 = f1(x1)\n",
    "y2 = f1(x2)\n",
    "area = reg_area((x1, y1), (x2, y2))\n",
    "print(\"此梯形的面积为：\", area)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 3. 近似求解不规则图形的面积"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "请输入第一个点的横坐标值： -5\n",
      "请输入第二个点的横坐标值： 6\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD4CAYAAAD1jb0+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3dd3xUVd7H8c8vnRQgkAQCCSGhhhogNAUWQVkWWLtrYRVdbGvvfS2rrq6routaFkFxFXuDRVlFBaRIMJTQQgsJLUBCgJCElElynj8yPg8Pm5AhzOTOnfm9X6+8yEzuzHxH9OvJnXPPEWMMSiml7CfA6gBKKaWaRgtcKaVsSgtcKaVsSgtcKaVsSgtcKaVsKqg5XywmJsZ07ty5OV9SKaVsb9WqVQeNMbEn3t+sBd65c2cyMzOb8yWVUsr2RGRnfffrKRSllLIpLXCllLIpLXCllLIpLXCllLIpLXCllLIplwtcRAJFZI2IzHPeThaRDBHZJiIfiUiI52IqpZQ60amMwG8Hso+7/VdgmjGmG3AYmOrOYEoppU7OpQIXkQRgIjDDeVuAMcCnzkPeAc73RECllLKzY1XVPPHvjewqOub253Z1BP4ScB9Q67zdFjhijKl23t4DdKzvgSJyvYhkikhmYWHhaYVVSim7+XJNPm8vy+NASYXbn7vRAheRSUCBMWbV8XfXc2i9O0MYY6YbY9KNMemxsf91JahSSvksYwzvLM+jV3xL0pOi3f78rlxKfyZwrohMAMKAltSNyFuLSJBzFJ4A5Ls9nVJK2dhPO4rYcqCE5y7uR92ZZ/dqdARujHnQGJNgjOkMXAb8YIyZDCwELnYeNgWY4/Z0SillY+8szyM6PJhz+3fwyPOfzjzw+4G7RGQ7defEZ7on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KIBIrIGhGZZ3UWdxKR1iLyqfO/t2wRGe6u59YCb4SIJALnALuszuJmC4A+xph+wFbgQYvznBYRCQReBX4D9AIuF5Fe1qZym2rgbmNMKjAMuNmH3tvxbgeyrQ7hAS8D/zHG9AT648b3qAXeuGnAfYBPfdprjPnWGFPtvLkCSLAyjxsMAbYbY3YYY6qAD4HzLM7kFsaYfcaY1c7vS6grgI7WpnIvEUkAJgIzrM7iTiLSEhgFzAQwxlQZY4646/m1wE9CRM4F9hpjsqzO4mF/AOZbHeI0dQR2H3d7Dz5WcgAi0hkYAGRYm8TtXqJuoFRrdRA3SwEKgbedp4dmiEiEu57c7zc1FpHvgPb1/Ohh4CFgXPMmcp+TvTdjzBznMQ9T9yv67ObM5gH1bTHvU781iUgk8BlwhzHmqNV53EVEJgEFxphVIjLa6jxuFgQMBG41xmSIyMvAA8Cf3PXkfs0Yc3Z994tIXyAZyBIRqDvFsFpEhhhj9jdjxCZr6L39QkSmAJOAscb+FwTsARKPu50A5FuUxe1EJJi68p5tjPnc6jxudiZwrohMAMKAliLynjHm9xbncoc9wB5jzC+/MX1KXYG7hV7I4yIRyQPSjTE+sVqaiIwHXgR+ZYwptDrP6RKRIOo+jB0L7AV+Bq4wxmy0NJgbSN0I4h3gkDHmDqvzeJJzBH6PMWaS1VncRUSWANcaY7aIyONAhDHmXnc8t9+PwP3YP4BQYIHzN4wVxpgbrY3UdMaYahG5BfgGCATe8oXydjoTuBJYLyJrnfc9ZIz52sJMynW3ArNFJATYAVzjrifWEbhSStmUzkJRSimb0gJXSimb0gJXSimb0gJXSimb0gJXSimb0gJXSimb0gJXSimb+h9VqGsgUaiI9AAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "from IPython import display\n",
    "\n",
    "def f(x):\n",
    "    return x**2+4\n",
    "\n",
    "def irr_area(x1, x2, intervals = 1000):\n",
    "    if x1 <= x2:\n",
    "        x_left = x1\n",
    "        x_right = x2\n",
    "    else:\n",
    "        x_left = x2\n",
    "        x_right = x1\n",
    "    dx = (x_right-x_left)/intervals\n",
    "    area = 0\n",
    "    x_temp = x_left\n",
    "    for i in range(intervals):\n",
    "        area_temp = dx * (x_temp**2+4)\n",
    "        area += area_temp\n",
    "        x_temp += dx\n",
    "    return area\n",
    "\n",
    "x1 = float(input(\"请输入第一个点的横坐标值：\"))\n",
    "x2 = float(input(\"请输入第二个点的横坐标值：\"))\n",
    "y1 = f(x1)\n",
    "y2 = f(x2)\n",
    "\n",
    "x_temp = np.linspace(x1, x2, 1000)\n",
    "y_temp = f(x_temp)\n",
    "plt.plot(x_temp, y_temp)\n",
    "plt.show()\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.54655399999953\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.60638850000103\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.6264319259281\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.63647212499885\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.64250216000121\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.6465246481508\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.64939906122743\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.65155553124094\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.65323317695757\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.65457554001145\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.65567399998451\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.65658949536427\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.65736422485648\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.65802833674203\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.6586039436891\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.6591076328101\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.65955208997593\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.6599471831308\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.66030070358764\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.66061888501886\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.66090677401402\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.6611684999935\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.66140747449793\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.66162654049498\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.66182808641673\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.66201413312098\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.6621864023816\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.6623463699065\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.66249530797091\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.66263431925884\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.66276436422095\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.66288628320905\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.66300081479355\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.66310861071386\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.66321024818686\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.66330624020284\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.66339704452403\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.66348307062003\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.66356468600296\n",
      "此函数图像在这两点与横坐标轴之间围成的图形面积近似为： 157.66364222124224\n"
     ]
    }
   ],
   "source": [
    "for i in range(40):\n",
    "    area = irr_area(-5, 6, 500*(i+1))\n",
    "    print(\"此函数图像在这两点与横坐标轴之间围成的图形面积近似为：\", area)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
